import util.tool as tool


# 全部组件
components = tool.read_json("data/component.json")
# JSON
jsons = tool.read_json("data-output.json")

print("=======================")


# 匹配组件
def match_component_info(keyword):
    for component in components:
        if keyword in component["data"]["keyword"]:
            return component
    return None


# 匹配对应组件
for item in jsons:
    result = match_component_info(item["type"])
    if result:
        component = result["data"]
        item["component"] = {
            "componentName": component["componentName"],
            "props": component["props"],
        }
        # print("匹配到组件", json.dumps(item))
        print("匹配到组件", item)
